/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadCliente.java
 *
 * Created on 11/10/2011, 09:08:25
 */
package visao;

import fachada.FachadaBDR;
import java.sql.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFormattedTextField;
import util.ErroAcessoRepositorioException;
import util.Util;

/**
 *
 * @author Administrador
 */
public class CadCliente extends javax.swing.JFrame {

    /** Creates new form CadCliente */
    public CadCliente() {
        initComponents();

        this.setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane_Cliente = new javax.swing.JTabbedPane();
        jPanel_Cliente = new javax.swing.JPanel();
        jLabel_Nome = new javax.swing.JLabel();
        jLabel_Cpf = new javax.swing.JLabel();
        jLabel_Sexo = new javax.swing.JLabel();
        jLabel_DtNascimento = new javax.swing.JLabel();
        jLabel_DtCadastro = new javax.swing.JLabel();
        jTextField_Nome = new javax.swing.JTextField();
        jTextField_Cpf = new javax.swing.JTextField();
        jComboBox_Sexo = new javax.swing.JComboBox();
        jTextField_DtNascimento = new javax.swing.JTextField();
        jTextField_DtCadastro = new javax.swing.JTextField();
        jPanel_Endereco = new javax.swing.JPanel();
        jLabel_Rua = new javax.swing.JLabel();
        jTextField_Rua = new javax.swing.JTextField();
        jLabel_Numero = new javax.swing.JLabel();
        jTextField_Numero = new javax.swing.JTextField();
        jLabel_Cep = new javax.swing.JLabel();
        jTextField_Cep = new javax.swing.JTextField();
        jLabel_Bairro = new javax.swing.JLabel();
        jTextField_Bairro = new javax.swing.JTextField();
        jLabel_Cidade = new javax.swing.JLabel();
        jTextField_Cidade = new javax.swing.JTextField();
        jTextField_Telefone = new javax.swing.JTextField();
        jComboBox_Uf = new javax.swing.JComboBox();
        jComboBox_Pais = new javax.swing.JComboBox();
        jButton_Ok = new javax.swing.JButton();
        jButton_Cancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel_Nome.setText("Nome :");

        jLabel_Cpf.setText("CPF :");

        jLabel_Sexo.setText("Sexo :");

        jLabel_DtNascimento.setText("Data Nascimento :");

        jLabel_DtCadastro.setText("Data Cadastro :");

        jTextField_Cpf = new JFormattedTextField(Util.setMascara("###.###.###-##"));

        jComboBox_Sexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "---","Masculino","Feminino" }));
        jComboBox_Sexo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox_SexoActionPerformed(evt);
            }
        });

        jTextField_DtNascimento = new JFormattedTextField(Util.setMascara("##/##/####"));

        jTextField_DtCadastro = new JFormattedTextField(Util.setMascara("##/##/####"));

        javax.swing.GroupLayout jPanel_ClienteLayout = new javax.swing.GroupLayout(jPanel_Cliente);
        jPanel_Cliente.setLayout(jPanel_ClienteLayout);
        jPanel_ClienteLayout.setHorizontalGroup(
            jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ClienteLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ClienteLayout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel_ClienteLayout.createSequentialGroup()
                                .addComponent(jLabel_Cpf)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField_Cpf, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel_ClienteLayout.createSequentialGroup()
                                .addComponent(jLabel_Sexo)
                                .addGap(18, 18, 18)
                                .addComponent(jComboBox_Sexo, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel_ClienteLayout.createSequentialGroup()
                                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel_DtCadastro)
                                    .addComponent(jLabel_DtNascimento))
                                .addGap(30, 30, 30)
                                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTextField_DtCadastro)
                                    .addComponent(jTextField_DtNascimento, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE))))
                        .addGap(480, 480, 480))
                    .addGroup(jPanel_ClienteLayout.createSequentialGroup()
                        .addComponent(jLabel_Nome)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTextField_Nome, javax.swing.GroupLayout.PREFERRED_SIZE, 432, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(207, 207, 207))))
        );
        jPanel_ClienteLayout.setVerticalGroup(
            jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ClienteLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_Nome)
                    .addComponent(jTextField_Nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_Cpf)
                    .addComponent(jTextField_Cpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_Sexo)
                    .addComponent(jComboBox_Sexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_DtNascimento)
                    .addComponent(jTextField_DtNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addGroup(jPanel_ClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_DtCadastro)
                    .addComponent(jTextField_DtCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(73, Short.MAX_VALUE))
        );

        jTabbedPane_Cliente.addTab("Cliente", jPanel_Cliente);

        jLabel_Rua.setText("Rua :");

        jLabel_Numero.setText("Numero :");

        jLabel_Cep.setText("CEP :");

        jTextField_Cep = new JFormattedTextField(Util.setMascara("##.###-###"));

        jLabel_Bairro.setText("Bairro :");

        jLabel_Cidade.setText("Cidade :");

        jTextField_Telefone = new JFormattedTextField(Util.setMascara("(##)####-####"));

        jComboBox_Uf.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "----", "AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO" }));

        jComboBox_Pais.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "Brasil" }));

        javax.swing.GroupLayout jPanel_EnderecoLayout = new javax.swing.GroupLayout(jPanel_Endereco);
        jPanel_Endereco.setLayout(jPanel_EnderecoLayout);
        jPanel_EnderecoLayout.setHorizontalGroup(
            jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                        .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel_Rua, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel_Numero, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel_Bairro, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel_Cidade, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                                .addComponent(jTextField_Cidade, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(136, 136, 136)
                                .addComponent(jTextField_Telefone, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTextField_Bairro, javax.swing.GroupLayout.PREFERRED_SIZE, 416, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                                .addComponent(jTextField_Numero, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                                .addGap(76, 76, 76)
                                .addComponent(jLabel_Cep, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField_Cep, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(147, 147, 147))
                            .addComponent(jTextField_Rua, javax.swing.GroupLayout.PREFERRED_SIZE, 427, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                        .addGap(110, 110, 110)
                        .addComponent(jComboBox_Uf, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(173, 173, 173)
                        .addComponent(jComboBox_Pais, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(193, 193, 193))
        );
        jPanel_EnderecoLayout.setVerticalGroup(
            jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField_Cep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_Cep)))
                    .addGroup(jPanel_EnderecoLayout.createSequentialGroup()
                        .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel_Rua)
                            .addComponent(jTextField_Rua, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel_Numero)
                            .addComponent(jTextField_Numero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel_Bairro)
                            .addComponent(jTextField_Bairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel_Cidade)
                            .addComponent(jTextField_Cidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField_Telefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addGroup(jPanel_EnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBox_Pais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_Uf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(83, Short.MAX_VALUE))
        );

        jTabbedPane_Cliente.addTab("Endereço", jPanel_Endereco);

        jButton_Ok.setText("OK");
        jButton_Ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_OkActionPerformed(evt);
            }
        });

        jButton_Cancelar.setText("Cancelar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane_Cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 563, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(60, 60, 60)
                        .addComponent(jButton_Ok, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(50, 50, 50)
                        .addComponent(jButton_Cancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane_Cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Ok)
                    .addComponent(jButton_Cancelar))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox_SexoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_SexoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox_SexoActionPerformed

    private void jButton_OkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_OkActionPerformed
        // TODO add your handling code here:

        int IdCliente = 0;
        String nome = jTextField_Nome.getText();
        String cpf = jTextField_Cpf.getText();
        int sexo = Integer.parseInt(((util.KeyValue) jComboBox_Sexo.getSelectedItem()).getValue());
        Date dtNascimento = Date.valueOf(Util.formatarDataBanco(jTextField_DtNascimento.getText()));
        Date dtCadastro = Date.valueOf(Util.formatarDataBanco(jTextField_DtCadastro.getText()));

        
        
        try {
        
            FachadaBDR objFachadaBDR = FachadaBDR.getInstancia();
        
            
        
        } catch (ErroAcessoRepositorioException ex) {
            Logger.getLogger(CadCliente.class.getName()).log(Level.SEVERE, null, ex);
        }
        


    }//GEN-LAST:event_jButton_OkActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CadCliente().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_Cancelar;
    private javax.swing.JButton jButton_Ok;
    private javax.swing.JComboBox jComboBox_Pais;
    private javax.swing.JComboBox jComboBox_Sexo;
    private javax.swing.JComboBox jComboBox_Uf;
    private javax.swing.JLabel jLabel_Bairro;
    private javax.swing.JLabel jLabel_Cep;
    private javax.swing.JLabel jLabel_Cidade;
    private javax.swing.JLabel jLabel_Cpf;
    private javax.swing.JLabel jLabel_DtCadastro;
    private javax.swing.JLabel jLabel_DtNascimento;
    private javax.swing.JLabel jLabel_Nome;
    private javax.swing.JLabel jLabel_Numero;
    private javax.swing.JLabel jLabel_Rua;
    private javax.swing.JLabel jLabel_Sexo;
    private javax.swing.JPanel jPanel_Cliente;
    private javax.swing.JPanel jPanel_Endereco;
    private javax.swing.JTabbedPane jTabbedPane_Cliente;
    private javax.swing.JTextField jTextField_Bairro;
    private javax.swing.JTextField jTextField_Cep;
    private javax.swing.JTextField jTextField_Cidade;
    private javax.swing.JTextField jTextField_Cpf;
    private javax.swing.JTextField jTextField_DtCadastro;
    private javax.swing.JTextField jTextField_DtNascimento;
    private javax.swing.JTextField jTextField_Nome;
    private javax.swing.JTextField jTextField_Numero;
    private javax.swing.JTextField jTextField_Rua;
    private javax.swing.JTextField jTextField_Telefone;
    // End of variables declaration//GEN-END:variables
}
